<template>
  <div class="fault-service-container">
    <div class="choose-container">
      <a-select class="choose-container-select" show-search default-value="全部" placeholder="请选择" option-filter-prop="children"
                :filter-option="districtFilterOption" @focus="handleFocus" @blur="handleBlur" @change="handleDistrictChange"
      >
        <a-select-option v-for="provinceItem in provinceData" :key="provinceItem" :value="provinceItem">
          {{provinceItem}}
        </a-select-option>
      </a-select>
      <a-select class="choose-container-select" show-search default-value="全部" placeholder="请选择" option-filter-prop="children"
                :filter-option="dateFilterOption" @focus="handleFocus" @blur="handleBlur" @change="handleDateChange"
      >
        <a-select-option v-for="dataItem in dateData" :key="dataItem" :value="dataItem">
          {{dataItem}}
        </a-select-option>
      </a-select>
      <span class="month-container" v-show="showTimePicker">
        <a-month-picker placeholder="选择月份" :defaultValue="doHandleDate" @change="onMonthChange" :locale="locale"  />
      </span>
    </div>
    <div>
      <a-row type="flex" justify="space-around" class="chart-row">
        <a-col :span="7" class="gutter-box">
          <device-type-container :deviceTypeData="deviceTypeData" :deviceTypeResultData="deviceTypeResultData" />
        </a-col>
        <a-col :span="7" class="gutter-box">
          <guarantee-state-container :guaranteeStateData="guaranteeStateData" :guaranteeStateResultData="guaranteeStateResultData" />
        </a-col>
        <a-col :span="7" class="gutter-box">
          <bill-state-container :billStateData="billStateData" :billStateResultData="billStateResultData" />
        </a-col>
      </a-row>
      <a-row type="flex" justify="space-around" class="chart-row">
        <a-col :span="7" class="gutter-box">
          <task-type-container :taskTypeData="taskTypeData" :taskTypeResultData="taskTypeResultData" />
        </a-col>
        <a-col :span="7" class="gutter-box">
          <service-attitude-container :serviceAttitudeData="serviceAttitudeData" :serviceAttitudeResultData="serviceAttitudeResultData" />
        </a-col>
        <a-col :span="7" class="gutter-box">
          <district-statics-container :districtStaticsData="districtStaticsData" :districtStaticsResultData="districtStaticsResultData" />
        </a-col>
      </a-row>
    </div>
  </div>
</template>

<script>
  // 获取时间的方法;
  const now = new Date(); //当前日期
  const nowDay = now.getDate(); //当前日
  const nowYear = now.getFullYear(); //当前年
  const nowMonth = now.getMonth() + 1; //当前月,月份获取的数字为[0--11]，所以实际月份数字比获取数字大1；

  // 日期格式化
  function formatDate (date) {
    //console.log(date);
    let myyear = date.getFullYear();
    let mymonth = date.getMonth();
    let myday = date.getDate();
    if(mymonth < 10){
      mymonth = "0" + mymonth;
    }
    if(myday < 10){
      myday = "0" + myday;
    }
    return (myyear + "-" + mymonth + "-" + myday);
  }

  // 获得七天前开始日期
  function getPreSevenDate () {
    const weekStartDate = new Date(nowYear, nowMonth, nowDay - 7);
    return formatDate(weekStartDate);
  }

  // 获得本月的开始日期
  function getMonthStartDate (){
    const monthStartDate = new Date(nowYear, nowMonth, 1);
    return formatDate(monthStartDate);
  }

  // 获取本年本月时间;
  function doHandleDate () {
    const myDate = new Date();
    const tYear = myDate.getFullYear();
    const tMonth = myDate.getMonth();
    let m = tMonth + 1;
    if (m.toString().length === 1) {
      m = "0" + m;
    }
    return tYear +'-'+ m;
  }

  // 获取明天的时间;
  function tomorrowTime () {
    let nowDate = new Date();
    nowDate.setTime(nowDate.getTime() + 24 * 60 * 60 * 1000);
    let endTime = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + nowDate.getDate();
    return endTime;
  }

  // 过去一年的时间
  function getPassYearFormatDate () {
    let nowDate = new Date();
    let date = new Date(nowDate);
    date.setDate(date.getDate()-365);
    let seperator1 = "-";
    let year = date.getFullYear();
    let month = date.getMonth() + 1;
    let strDate = date.getDate();
    if (month >= 1 && month <= 9) {
      month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
      strDate = "0" + strDate;
    }
    let currentdate = year + seperator1 + month + seperator1 + strDate;
    return currentdate;
  }

  // 获取过去半年的时间;
  function getPastHalfYear () {
    // 先获取当前时间
    let curDate = (new Date()).getTime();
    // 将半年的时间单位换算成毫秒
    let halfYear = 365 / 2 * 24 * 3600 * 1000;
    let pastResult = curDate - halfYear;  // 半年前的时间（毫秒单位）
    // 日期函数，定义起点为半年前
    let pastDate = new Date(pastResult),
      pastYear = pastDate.getFullYear(),
      pastMonth = pastDate.getMonth() + 1,
      pastDay = pastDate.getDate();
    return pastYear + '-' + pastMonth + '-' + pastDay;
  }

  import DeviceTypeContainer from './deviceTypeContainer'
  import GuaranteeStateContainer from './guaranteeStateContainer'
  import BillStateContainer from './billStateContainer'
  import TaskTypeContainer from './taskTypeContainer'
  import ServiceAttitudeContainer from './serviceAttitudeContainer'
  import DistrictStaticsContainer from './districtStaticsContainer'
  import locale from 'ant-design-vue/es/date-picker/locale/zh_CN';
  import moment from 'moment';
  import 'moment/locale/zh-cn';
  import api from '@/server/userConfig';
  import localIp from '@/api/global_variable';
  export default {
    name: 'StaticsService',
    components: {
      DeviceTypeContainer,
      GuaranteeStateContainer,
      BillStateContainer,
      TaskTypeContainer,
      ServiceAttitudeContainer,
      DistrictStaticsContainer,
    },
    data () {
      return {
        provinceData: ['全部', '华中片区', '华北片区', '华东片区', '东北片区', '西北片区', '深圳分公司', '宁波分公司', '重庆分公司',
          '沈阳分公司', '云南分公司', '泉州分公司'],
        dateData: ['全部', '最近一周', '本月', '半年','一年', '自定义'],
        showTimePicker: false,
        locale: locale,
        deviceTypeData: [],
        deviceTypeResultData: {},
        guaranteeStateData: [],
        guaranteeStateResultData: {},
        billStateData: [],
        billStateResultData: {},
        taskTypeData: [],
        taskTypeResultData: {},
        serviceAttitudeData: [],
        serviceAttitudeResultData: {},
        districtStaticsData: [],
        districtStaticsResultData: {},
        districtValue: '全部',
        dateValue: '全部',
        dateString: ''
      }
    },
    mounted () {
      const initialDistrict = '全部';
      const endTime = tomorrowTime();
      this.initDeviceType(initialDistrict, '2017-01-01', endTime);
      this.initGuaranteeState(initialDistrict, '2017-01-01', endTime);
      this.initBillState(initialDistrict, '2017-01-01', endTime);
      this.initTaskType(initialDistrict, '2017-01-01', endTime);
      this.initServiceAttitude(initialDistrict, '2017-01-01', endTime);
      this.initDistrictStatics(initialDistrict, '2017-01-01', endTime);
    },
    computed: {
      doHandleDate: function () {
        const myDate = new Date();
        const tYear = myDate.getFullYear();
        const tMonth = myDate.getMonth();
        let m = tMonth + 1;
        if (m.toString().length === 1) {
          m = "0" + m;
        }
        return moment(tYear + '-' + m);
      }
    },
    methods: {
      // 选择区域;
      handleDistrictChange (value) {
        this.districtValue = value;
        let newTimeValue = '';
        let startTime = '';
        if (this.showTimePicker === true) {
          newTimeValue = this.dateString || (doHandleDate() + '-01');
        } else {
          newTimeValue = this.dateValue;
        }
        if (newTimeValue === "最近一周") {
          startTime = getPreSevenDate();
        } else if (newTimeValue === "本月") {
          startTime = getMonthStartDate();
        } else if (newTimeValue === "半年") {
          startTime = getPastHalfYear();
        } else if (newTimeValue === "一年") {
          startTime = getPassYearFormatDate();
        } else if (newTimeValue === "全部") {
          startTime = "2017-01-01";
        } else {
          startTime = newTimeValue;
        }
        // 切换后,调用接口;
        console.log(localIp.localIp + '/servicePieChart.action?ownDistrict='+ this.districtValue +'&startTime='+ startTime +
          '&endTime='+ tomorrowTime() +'&statisticsType=设备类型');
        this.initDeviceType(this.districtValue, startTime, tomorrowTime());
        this.initGuaranteeState(this.districtValue, startTime, tomorrowTime());
        this.initBillState(this.districtValue, startTime, tomorrowTime());
        this.initTaskType(this.districtValue, startTime, tomorrowTime());
        this.initServiceAttitude(this.districtValue, startTime, tomorrowTime());
        this.initDistrictStatics(this.districtValue, startTime, tomorrowTime());
      },
      districtFilterOption (input, option) {
        return (
          option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
        );
      },
      handleDateChange (value) {
        this.dateValue = value;
        if (value === '自定义') {
          this.showTimePicker = true;
          let startTime = this.dateString || (doHandleDate() + '-01');
          console.log(localIp.localIp + '/servicePieChart.action?ownDistrict='+ this.districtValue +'&startTime='+ startTime +
            '&endTime='+ tomorrowTime() +'&statisticsType=设备类型');
          this.initDeviceType(this.districtValue, startTime, tomorrowTime());
          this.initGuaranteeState(this.districtValue, startTime, tomorrowTime());
          this.initBillState(this.districtValue, startTime, tomorrowTime());
          this.initTaskType(this.districtValue, startTime, tomorrowTime());
          this.initServiceAttitude(this.districtValue, startTime, tomorrowTime());
          this.initDistrictStatics(this.districtValue, startTime, tomorrowTime());
        } else {
          this.showTimePicker = false;
          let startTime = '';
          if (this.dateValue === "最近一周") {
            startTime = getPreSevenDate();
          } else if (this.dateValue === "本月") {
            startTime = getMonthStartDate();
          } else if (this.dateValue === "半年") {
            startTime = getPastHalfYear();
          } else if (this.dateValue === "一年") {
            startTime = getPassYearFormatDate();
          } else if (this.dateValue === "全部") {
            startTime = "2017-01-01";
          }
          console.log(localIp.localIp + '/servicePieChart.action?ownDistrict='+ this.districtValue +'&startTime='+ startTime +
            '&endTime='+ tomorrowTime() +'&statisticsType=设备类型');
          this.initDeviceType(this.districtValue, startTime, tomorrowTime());
          this.initGuaranteeState(this.districtValue, startTime, tomorrowTime());
          this.initBillState(this.districtValue, startTime, tomorrowTime());
          this.initTaskType(this.districtValue, startTime, tomorrowTime());
          this.initServiceAttitude(this.districtValue, startTime, tomorrowTime());
          this.initDistrictStatics(this.districtValue, startTime, tomorrowTime());
        }
      },
      dateFilterOption (input, option) {
        return (
          option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
        );
      },
      handleBlur () {},
      handleFocus () {},
      onMonthChange (date, dateString) {
        let startTime = dateString + '-01';
        this.dateString = dateString + '-01';
        console.log(localIp.localIp + '/servicePieChart.action?ownDistrict='+ this.districtValue +'&startTime='+ startTime +
          '&endTime='+ tomorrowTime() +'&statisticsType=设备类型');
        this.initDeviceType(this.districtValue, startTime, tomorrowTime());
        this.initGuaranteeState(this.districtValue, startTime, tomorrowTime());
        this.initBillState(this.districtValue, startTime, tomorrowTime());
        this.initTaskType(this.districtValue, startTime, tomorrowTime());
        this.initServiceAttitude(this.districtValue, startTime, tomorrowTime());
        this.initDistrictStatics(this.districtValue, startTime, tomorrowTime());
      },
      // 设备类型;
      async initDeviceType (initialDistrict, startTime, endTime) {
        const result = await api.reqDeviceType({
          ownDistrict: initialDistrict,
          startTime: startTime,
          endTime: endTime,
          statisticsType: '设备类型',
        });
        let deviceTypeData = [];
        if (result.MsgCode !== 0) {
          deviceTypeData.push(
            {name: '加工中心', value: 0},
            {name: '铣   床', value: 0},
            {name: '车   床', value: 0},
            {name: '机 器 人', value: 0},
            {name: '五   轴', value: 0},
            {name: '磨   床', value: 0},
            {name: '智能产线', value: 0}
          );
          const deviceTypeResultData = {
            加工中心: { number: 0, percent: 0 },
            铣床: { number: 0, percent: 0 },
            车床: { number: 0, percent: 0 },
            机器人: { number: 0, percent: 0 },
            五轴: { number: 0, percent: 0 },
            磨床: { number: 0, percent: 0 },
            智能产线: { number: 0, percent: 0 }
          };
          this.deviceTypeData = deviceTypeData;
          this.deviceTypeResultData = deviceTypeResultData;
        } else {
          let resultData = result.Data;
          if (!resultData.加工中心) {
            resultData.加工中心 = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData.铣床) {
            resultData.铣床 = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData.车床) {
            resultData.车床 = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData.机器人) {
            resultData.机器人 = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData.五轴) {
            resultData.五轴 = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData.磨床) {
            resultData.磨床 = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData.智能产线) {
            resultData.智能产线 = {
              percent: 0,
              number: 0
            }
          }
          deviceTypeData.push(
            {name: '加工中心', value: (resultData.加工中心.percent * 100).toFixed(1)},
            {name: '铣   床', value: (resultData.铣床.percent * 100).toFixed(1)},
            {name: '车   床', value: (resultData.车床.percent * 100).toFixed(1)},
            {name: '机 器 人', value: (resultData.机器人.percent * 100).toFixed(1)},
            {name: '五   轴', value: (resultData.五轴.percent * 100).toFixed(1)},
            {name: '磨   床', value: (resultData.磨床.percent * 100).toFixed(1)},
            {name: '智能产线', value: (resultData.智能产线.percent * 100).toFixed(1)}
          );
          this.deviceTypeData = deviceTypeData;
          this.deviceTypeResultData = resultData;
        }
      },
      // 保修状态;
      async initGuaranteeState (initialDistrict, startTime, endTime) {
        const result = await api.reqGuaranteeState({
          ownDistrict: initialDistrict,
          startTime: startTime,
          endTime: endTime,
          statisticsType: '保修状态',
        });
        let guaranteeStateData = [];
        if (result.MsgCode !== 0) {
          guaranteeStateData.push(
            {name: '保内免费', value: 0},
            {name: '保内收费', value: 0},
            {name: '保外免费', value: 0},
            {name: '保外收费', value: 0}
          );
          const guaranteeStateResultData = {
            保内免费: {number: 0, percent: 0},
            保内收费: {number: 0, percent: 0},
            保外免费: {number: 0, percent: 0},
            保外收费: {number: 0, percent: 0}
          };
          this.guaranteeStateData = guaranteeStateData;
          this.guaranteeStateResultData = guaranteeStateResultData;
        } else {
          let resultData = result.Data;
          if(!resultData.保内免费){
            resultData.保内免费 = {
              percent: 0,
              number: 0
            }
          }
          if(!resultData.保内收费){
            resultData.保内收费 = {
              percent: 0,
              number: 0
            }
          }
          if(!resultData.保外免费){
            resultData.保外免费 = {
              percent: 0,
              number: 0
            }
          }
          if(!resultData.保外收费){
            resultData.保外收费 = {
              percent: 0,
              number: 0
            }
          }
          guaranteeStateData.push(
            {name:'保内免费', value: (resultData.保内免费.percent * 100).toFixed(1)},
            {name:'保内收费', value: (resultData.保内收费.percent * 100).toFixed(1)},
            {name:'保外免费', value: (resultData.保外免费.percent * 100).toFixed(1)},
            {name:'保外收费', value: (resultData.保外收费.percent * 100).toFixed(1)}
          );
          this.guaranteeStateData = guaranteeStateData;
          this.guaranteeStateResultData = resultData;
        }
      },
      // 订单状态;
      async initBillState (initialDistrict, startTime, endTime) {
        const result = await api.reqBillState({
          ownDistrict: initialDistrict,
          startTime: startTime,
          endTime: endTime,
          statisticsType: '订单状态',
        });
        let billStateData = [];
        if (result.MsgCode !== 0) {
          billStateData.push(
            {name:'已报单', value: 0},
            {name:'已指派', value: 0},
            {name:'进行中', value: 0},
            {name:'暂  停', value: 0},
            {name:'待回访', value: 0},
            {name:'完  成', value: 0}
          );
          const billStateResultData = {
            1: { number: 0, percent: 0 },
            2: { number: 0, percent: 0 },
            5: { number: 0, percent: 0 },
            6: { number: 0, percent: 0 },
            8: { number: 0, percent: 0 },
            9: { number: 0, percent: 0 },
          };
          this.billStateData = billStateData;
          this.billStateResultData = billStateResultData;
        } else {
          const resultData = result.Data;
          if(!resultData[1]){
            resultData[1] = {
              percent: 0,
              number: 0
            }
          }
          if(!resultData[2]){
            resultData[2] = {
              percent: 0,
              number: 0
            }
          }
          if(!resultData[8]){
            resultData[8] = {
              percent: 0,
              number: 0
            }
          }
          if(!resultData[9]){
            resultData[9] = {
              percent: 0,
              number: 0
            }
          }
          if(!resultData[5]){
            resultData[5] = {
              percent: 0,
              number: 0
            }
          }
          if(!resultData[6]){
            resultData[6] = {
              percent: 0,
              number: 0
            }
          }
          billStateData.push(
            {name:'已报单', value: (resultData[1].percent * 100).toFixed(1)},
            {name:'已指派', value: (resultData[2].percent * 100).toFixed(1)},
            {name:'进行中', value: (resultData[8].percent * 100).toFixed(1)},
            {name:'暂  停', value: (resultData[9].percent * 100).toFixed(1)},
            {name:'待回访', value: (resultData[5].percent * 100).toFixed(1)},
            {name:'完  成', value: (resultData[6].percent * 100).toFixed(1)}
          );
          this.billStateData = billStateData;
          this.billStateResultData = resultData;
        }
      },
      // 任务类型;
      async initTaskType (initialDistrict, startTime, endTime) {
        const result = await api.reqTaskType({
          ownDistrict: initialDistrict,
          startTime: startTime,
          endTime: endTime,
          statisticsType: '任务类型',
        });
        let taskTypeData = [];
        if (result.MsgCode !== 0) {
          taskTypeData.push(
            {name:'设备调试', value: 0},
            {name:'故障报修', value: 0},
            {name:'技术咨询', value: 0},
            {name:'驻厂服务', value: 0},
            {name:'培训申请', value: 0},
            {name:'其  他', value: 0}
          );
          const taskTypeResultData = {
            设备调试: { number: 0, percent: 0 },
            故障报修: { number: 0, percent: 0 },
            技术咨询: { number: 0, percent: 0 },
            驻厂服务: { number: 0, percent: 0 },
            培训申请: { number: 0, percent: 0 },
            其他: { number: 0, percent: 0 },
          };
          this.taskTypeData = taskTypeData;
          this.taskTypeResultData = taskTypeResultData;
        } else {
          let resultData = result.Data;
          if(!resultData.设备调试){
            resultData.设备调试 = {
              percent: 0,
              number: 0
            }
          }
          if(!resultData.故障报修){
            resultData.故障报修 = {
              percent: 0,
              number: 0
            }
          }
          if(!resultData.技术咨询){
            resultData.技术咨询 = {
              percent: 0,
              number: 0
            }
          }
          if(!resultData.驻厂服务){
            resultData.驻厂服务 = {
              percent: 0,
              number: 0
            }
          }
          if(!resultData.培训申请){
            resultData.培训申请 = {
              percent: 0,
              number: 0
            }
          }
          if(!resultData.其他){
            resultData.其他 = {
              percent: 0,
              number: 0
            }
          }
          taskTypeData.push(
            {name:'设备调试', value: (resultData.设备调试.percent * 100).toFixed(1)},
            {name:'故障报修', value: (resultData.故障报修.percent * 100).toFixed(1)},
            {name:'技术咨询', value: (resultData.技术咨询.percent * 100).toFixed(1)},
            {name:'驻厂服务', value: (resultData.驻厂服务.percent * 100).toFixed(1)},
            {name:'培训申请', value: (resultData.培训申请.percent * 100).toFixed(1)},
            {name:'其  他', value: (resultData.其他.percent * 100).toFixed(1)}
          );
          this.taskTypeData = taskTypeData;
          this.taskTypeResultData = resultData;
        }
      },
      // 服务满意度;
      async initServiceAttitude (initialDistrict, startTime, endTime) {
        const result = await api.reqServiceAttitude({
          ownDistrict: initialDistrict,
          startTime: startTime,
          endTime: endTime,
          statisticsType: '服务满意度',
        });
        let serviceAttitudeData = [];
        if (result.MsgCode !== 0) {
          serviceAttitudeData.push(
            {name:'很  好', value: 0},
            {name:' 好', value: 0},
            {name:'一  般', value: 0},
            {name:'不  好', value: 0}
          );
          const serviceAttitudeResultData = {
            1: { percent: 0, number: 0 },
            2: { percent: 0, number: 0 },
            3: { percent: 0, number: 0 },
            4: { percent: 0, number: 0 },
          };
          this.serviceAttitudeData = serviceAttitudeData;
          this.serviceAttitudeResultData = serviceAttitudeResultData;
        } else {
          let resultData = result.Data;
          if (!resultData[1]) {
            resultData[1] = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData[2]) {
            resultData[2] = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData[3]) {
            resultData[3] = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData[4]) {
            resultData[4] = {
              percent: 0,
              number: 0
            }
          }
          serviceAttitudeData.push(
            {name: '很  好', value: (resultData[1].percent * 100).toFixed(1)},
            {name: ' 好', value: (resultData[2].percent * 100).toFixed(1)},
            {name: '一  般', value: (resultData[3].percent * 100).toFixed(1)},
            {name: '不  好', value: (resultData[4].percent * 100).toFixed(1)}
          );
          this.serviceAttitudeData = serviceAttitudeData;
          this.serviceAttitudeResultData = resultData;
        }
      },
      // 片区统计;
      async initDistrictStatics (initialDistrict, startTime, endTime) {
        const result = await api.reqDistrictStatics({
          ownDistrict: initialDistrict,
          startTime: startTime,
          endTime: endTime,
          statisticsType: '片区统计',
        });
        let districtStaticsData = [];
        if (result.MsgCode !== 0) {
          districtStaticsData.push(
            {name:'华中片区', value: 0},
            {name:'华北片区', value: 0},
            {name:'东北片区', value: 0},
            {name:'西北片区', value: 0},
            {name:'华东片区', value: 0},
            {name:'分 公 司', value: 0}
          );
          const districtStaticsResultData = {
            华中片区:{ percent: 0,number: 0 },
            华北片区: { percent: 0, number: 0 },
            东北片区: { percent: 0, number: 0 },
            西北片区: { percent: 0, number: 0 },
            华东片区: { percent: 0, number: 0 },
            分公司: { percent: 0, number: 0 },
            departCompany: { percent: 0, number: 0 },
          };
          this.districtStaticsData = districtStaticsData;
          this.districtStaticsResultData = districtStaticsResultData;
        } else {
          let resultData = result.Data;
          if (!resultData.华中片区) {
            resultData.华中片区 = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData.华北片区) {
            resultData.华北片区 = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData.东北片区) {
            resultData.东北片区 = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData.西北片区) {
            resultData.西北片区 = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData.华东片区) {
            resultData.华东片区 = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData.宁波分公司) {
            resultData.宁波分公司 = {
              percent: 0,
              number: 0
            }
          }
          if (!resultData.深圳分公司) {
            resultData.深圳分公司 = {
              percent: 0,
              number: 0
            };
          }
          if (!resultData.重庆分公司) {
            resultData.重庆分公司 = {
              percent: 0,
              number: 0
            };
          }
          resultData.departCompany = {
            percent: resultData.宁波分公司.percent + resultData.深圳分公司.percent + resultData.重庆分公司.percent,
            number: resultData.宁波分公司.number + resultData.深圳分公司.number + resultData.重庆分公司.number
          };
          districtStaticsData.push(
            {name:'华中片区', value: (resultData.华中片区.percent * 100).toFixed(1)},
            {name:'华北片区', value: (resultData.华北片区.percent * 100).toFixed(1)},
            {name:'东北片区', value: (resultData.东北片区.percent * 100).toFixed(1)},
            {name:'西北片区', value: (resultData.西北片区.percent * 100).toFixed(1)},
            {name:'华东片区', value: (resultData.华东片区.percent * 100).toFixed(1)},
            {name:'分 公 司', value: (resultData.departCompany.percent * 100).toFixed(1)}
          );
          this.districtStaticsData = districtStaticsData;
          this.districtStaticsResultData = resultData;
        }
      },
    }
  }
</script>

<style scoped="scoped">
  .fault-service-container {
    width: 100%;
    height: 100%;
    padding-bottom: 10px;
    position: relative;
  }
  .fault-service-container .choose-container{
    position: absolute;
    width: 750px;
    height: 35px;
    right: 50px;
    top: -70px;
  }
  .fault-service-container .choose-container .choose-container-select {
    width: 25%;
    margin-right: 2%;
  }
  .fault-service-container /deep/ .ant-calendar-picker-clear {
    pointer-events: none !important;
  }
  .fault-service-container .gutter-box {
    border: 1px solid #ccc;
    padding: 0;
    text-align: center;
  }
  .fault-service-container .chart-row {
    margin-top: 20px;
  }
</style>

